1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import { NextRequest } from "next/server";
import { buildHandler } from "@/app/api/v1/utils/handler";
import { zUpdateBookmarksRequestSchema } from "@karakeep/shared/types/bookmarks";
export const dynamic = "force-dynamic";
export const GET = (
req: NextRequest,
{ params }: { params: { bookmarkId: string } },
) =>
buildHandler({
req,
handler: async ({ api }) => {
const bookmark = await api.bookmarks.getBookmark({
bookmarkId: params.bookmarkId,
});
return { status: 200, resp: bookmark };
},
});
export const PATCH = (
req: NextRequest,
{ params }: { params: { bookmarkId: string } },
) =>
buildHandler({
req,
bodySchema: zUpdateBookmarksRequestSchema.omit({ bookmarkId: true }),
handler: async ({ api, body }) => {
const bookmark = await api.bookmarks.updateBookmark({
bookmarkId: params.bookmarkId,
...body!,
});
return { status: 200, resp: bookmark };
},
});
export const DELETE = (
req: NextRequest,
{ params }: { params: { bookmarkId: string } },
) =>
buildHandler({
req,
handler: async ({ api }) => {
await api.bookmarks.deleteBookmark({
bookmarkId: params.bookmarkId,
});
return { status: 204 };
},
});
|